(function(e){var i=null,t=null;if(BX["UploaderTemplateThumbnails"])return false;BX.UploaderTemplateThumbnails=function(e,i){this.id=e["id"];this.dialogName="BX.UploaderTemplateThumbnails";this.vars={filesCountForUpload:0};e["phpMaxFileUploads"]=10;if(!!e["copies"]){var t=1;for(var s in e["copies"]){if(e["copies"].hasOwnProperty(s)){t++}}e["phpMaxFileUploads"]=t*10}this.params=e;this.uploader=BX.Uploader.getInstance(e);this.init();return this};BX.UploaderTemplateThumbnails.prototype={init:function(){if(this.uploader.dialogName!="BX.Uploader"){BX.addClass(BX("bxuMain"+this.id),"bxu-thumbnails-simple")}this._onItemIsAdded=BX.delegate(this.onItemIsAdded,this);this._onFileIsAppended=BX.delegate(this.onFileIsAppended,this);BX.addCustomEvent(this.uploader,"onItemIsAdded",this._onItemIsAdded);BX.addCustomEvent(this.uploader,"onStart",BX.delegate(this.start,this));BX.addCustomEvent(this.uploader,"onFinish",BX.delegate(this.done,this));BX.addCustomEvent(this.uploader,"onTerminate",BX.delegate(this.terminate,this));BX.addCustomEvent(this.uploader,"onFileIsAppended",this._onFileIsAppended);BX.addCustomEvent(this.uploader,"onQueueIsChanged",BX.delegate(this.onChange,this));this._onUploadStart=BX.delegate(this.onUploadStart,this);this._onUploadProgress=BX.delegate(this.onUploadProgress,this);this._onUploadDone=BX.delegate(this.onUploadDone,this);this._onUploadError=BX.delegate(this.onUploadError,this);this._onUploadRestore=BX.delegate(this.onUploadRestore,this);this._onFileHasPreview=BX.delegate(this.onFileHasPreview,this);BX.bind(BX("bxuStartUploading"+this.id),"click",BX.delegate(this.uploader.submit,this.uploader));BX.bind(BX("bxuCancel"+this.id),"click",BX.delegate(this.uploader.stop,this.uploader));this.uploader.init(BX("bxuUploaderStart"+this.id));this.uploader.init(BX("bxuUploaderStartField"+this.id));BX.bind(BX("bxuReduced"+this.id),"click",BX.delegate(function(){BX.userOptions.save("fileman","uploader_html5","template","reduced");BX.addClass(BX("bxuReduced"+this.id),"bxu-templates-btn-active");BX.removeClass(BX("bxuEnlarge"+this.id),"bxu-templates-btn-active");BX.addClass(BX("bxuMain"+this.id),"bxu-main-block-reduced-size")},this));BX.bind(BX("bxuEnlarge"+this.id),"click",BX.delegate(function(){BX.userOptions.save("fileman","uploader_html5","template","full");BX.removeClass(BX("bxuReduced"+this.id),"bxu-templates-btn-active");BX.addClass(BX("bxuEnlarge"+this.id),"bxu-templates-btn-active");BX.removeClass(BX("bxuMain"+this.id),"bxu-main-block-reduced-size")},this));this.uploader.fileFields=!!this.uploader.fileFields?this.uploader.fileFields:{};this.uploader.fileFields.description=!!this.uploader.fileFields.description?this.uploader.fileFields.description:{}},onUploadStart:function(e){e.__progressBarWidth=1;var i=e.getPH("Thumb"),t=e.id,s,o=e.progress;BX.addClass(i,"bxu-item-loading");if(BX("bxu"+t+"ProgressBar")){BX.adjust(BX("bxu"+t+"ProgressBar"),{style:{width:e.__progressBarWidth+"%"}})}},onUploadProgress:function(e,i){var t=e.id;if(BX("bxu"+t+"ProgressBar")){e.__progressBarWidth=Math.max(e.__progressBarWidth,Math.ceil(i));BX.adjust(BX("bxu"+t+"ProgressBar"),{style:{width:e.__progressBarWidth+"%"}})}},onUploadDone:function(e,i,t){BX.defer_proxy(e.deleteFile,e)();this.vars["uploadedFilesCount"]++;BX("bxuUploaded"+this.id).innerHTML=this.vars["uploadedFilesCount"];BX("bxuUploadBar"+this.id).style.width=Math.ceil(this.vars["uploadedFilesCount"]/this.vars["filesCountForUpload"]*100)+"%"},onUploadError:function(e,i,t){var s=e.getPH("Thumb");BX.removeClass(s,"bxu-item-loading");BX.addClass(s,"bxu-item-error");s.innerHTML=this.params.errorThumb.replace("#error#",i.error)},onUploadRestore:function(e){var i=e.getPH("Thumb");BX.removeClass(i,"bxu-item-loading");BX.removeClass(i,"bxu-item-loading-with-error")},start:function(e,i){this.vars["uploadedFilesCount"]=this.uploader.queue.itUploaded.length;this.vars["filesCountForUpload"]+=i.filesCount;BX("bxuUploadBar"+this.id).style.width=Math.ceil(this.vars["uploadedFilesCount"]/this.vars["filesCountForUpload"])+"%";BX("bxuUploaded"+this.id).innerHTML=this.vars["uploadedFilesCount"];BX("bxuForUpload"+this.id).innerHTML=this.vars["filesCountForUpload"];BX.addClass(BX("bxuMain"+this.id),"bxu-thumbnails-loading")},done:function(e,i,t,s){this.vars["filesCountForUpload"]-=t.filesCount;BX.removeClass(BX("bxuMain"+this.id),"bxu-thumbnails-loading");BX("bxuUploaded"+this.id).innerHTML=this.vars["uploadedFilesCount"];if(!!s&&this.uploader.queue.itFailed.length<=0){var o=s.report.uploading[this.uploader.CID];if(!!o["redirectUrl"])BX.reload(o["redirectUrl"])}},terminate:function(e,i){this.vars["filesCountForUpload"]-=i.filesCount;BX.removeClass(BX("bxuMain"+this.id),"bxu-thumbnails-loading");BX("bxuUploaded"+this.id).innerHTML=this.vars["uploadedFilesCount"]},onChange:function(e){if(!!BX("bxuImagesCount"+this.id)){this.vars["filesCount"]=e.items.length;BX("bxuImagesCount"+this.id).innerHTML=e.items.length}},onItemIsAdded:function(e,i){BX.removeCustomEvent(this.uploader,"onItemIsAdded",this._onItemIsAdded);BX.removeClass(BX("bxuMain"+this.id),"bxu-thumbnails-start")},onFileHasPreview:function(e,i,t){},onFileIsAppended:function(e,s){if(s.dialogName=="BX.UploaderFile"||!BX.CanvasEditor){if(BX(e+"Edit"))BX.remove(BX(e+"Edit"));if(BX(e+"Turn"))BX.remove(BX(e+"Turn"));if(BX(e+"Thumb"))BX.addClass(BX(e+"Thumb"),"bx-bxu-thumb-file");if(BX(e+"Thumb"))BX.addClass(BX(e+"Thumb"),"bx-bxu-thumb-"+s.ext);if(BX(e+"Canvas")&&!BX(e+"Canvas").hasChildNodes())BX(e+"Canvas").innerHTML=['<span class="bx-bxu-thumb-file-icon bxu-item-',s.ext,'">','<span class="bxu-item-block-icon-holder"></span>',"</span>"].join("")}else{if(BX(e+"Edit"))BX.bind(BX(e+"Edit"),"click",BX.delegate(s.clickFile,s));if(BX(e+"Turn")){s.__onTurnCanvas=BX.delegate(function(e,i,s){if(t===null)t=new BX.Canvas;if(t){s.drawImage(e,0,0);t.copy(i,{width:e.width,height:e.height});t.rotate(true);this.applyFile(t.cnv,true)}},s);BX.bind(BX(e+"Turn"),"click",BX.delegate(function(){if(i===null&&!!BX.UploaderFileCnvConstr)i=new BX.UploaderFileCnvConstr;if(!!i){BX.adjust(i.getCanvas(),{props:{width:this.file.width,height:this.file.height}});i.push(this.file,this.__onTurnCanvas)}},s))}}BX.addCustomEvent(s,"onUploadStart",this._onUploadStart);BX.addCustomEvent(s,"onUploadProgress",this._onUploadProgress);BX.addCustomEvent(s,"onUploadDone",this._onUploadDone);BX.addCustomEvent(s,"onUploadError",this._onUploadError);BX.addCustomEvent(s,"onUploadRestore",this._onUploadRestore);BX.addCustomEvent(s,"onFileHasPreview",this._onFileHasPreview);if(BX(e+"Del"))BX.bind(BX(e+"Del"),"click",BX.delegate(function(){BX.removeCustomEvent(s,"onUploadStart",this._onUploadStart);BX.removeCustomEvent(s,"onUploadProgress",this._onUploadProgress);BX.removeCustomEvent(s,"onUploadDone",this._onUploadDone);BX.removeCustomEvent(s,"onUploadError",this._onUploadError);BX.removeCustomEvent(s,"onUploadRestore",this._onUploadRestore);BX.removeCustomEvent(s,"onFileHasPreview",this._onFileHasPreview);BX.unbindAll(BX(e+"Turn"));BX.unbindAll(BX(e+"Edit"));BX.unbindAll(BX(e+"Del"));s.deleteFile()},s))}}})(window);
//# sourceMappingURL=medialib_admin.map.js